package ExtraDemo.demo02.mycountdownlatch;

import java.util.concurrent.CountDownLatch;

public class ChildThread1 extends Thread{
    private CountDownLatch countDownLatch;

    public ChildThread1(CountDownLatch countDownLatch) {
        this.countDownLatch = countDownLatch;
    }

    @Override
    public void run() {
        //1.吃饺子
        for (int i = 1; i <= 10; i++) {
            System.out.println(getName()+"正在吃第"+i+"个饺子");
        }
        //2.吃完了说一声
        //每次吃完countdown方法，计数器减1
        countDownLatch.countDown();
    }
}
